// , 隔开？
interface IPerson {
    firstName:string, // 属性
    lastName:string, // 属性
    sayHi:()=>string // 方法
}

var doctor:IPerson = {
    firstName: "zhang",
    lastName: "san",
    sayHi: ():string => { return "hi" } 
}

console.log(doctor.firstName)
console.log(doctor.lastName)

// 联合类型
interface RunOption {
    program:string;
    commandLine: string | string[] |(()=> string)
}

var option:RunOption = {program:"project1", commandLine:"echo 123"}
var option2:RunOption = {program:"project2", commandLine:["echo", "123"]}
var option3:RunOption = {program:"project2", commandLine:()=> {return "hello"}}
console.log(option.commandLine)
console.log(option2.commandLine)
console.log(option3.commandLine)

// 接口内定义数组，数组下标可以是 数字或者string
interface List {
    [index:number]:string
}
var list1:List = ["hello","world"]
// 不同类型会编译错误
// var list3:List = [1,"world"]

interface Ages {
    [index:string]:number
}

var ages1:Ages = {};
ages1["zhangsan"] = 18;
ages1["lisi"] = 25;
console.log(ages1);

// 多接口继承用 extends ,继承的接口用 , 分开
interface Fun extends IPerson, List, RunOption {

}
// 此处需要指定 <Fun>
var f:Fun = <Fun>{}
f.firstName = "zhang"
f.lastName = "san"
f.program = "project x"
f.commandLine ="echo hello"
f.sayHi = ()=> {return "man"}
// f.prototype.email = "zeng@hotmail.com"
console.log(f)